package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.LeaveStatsDTO;
import com.ruoyi.system.service.ILeaveStatsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/leave/stats")
public class LeaveStatsController extends BaseController {

    @Resource
    private ILeaveStatsService leaveStatsService;

    @GetMapping
    public AjaxResult getLeaveStats(@RequestParam String type) {
        LeaveStatsDTO stats = leaveStatsService.getLeaveStatistics(type);
        return AjaxResult.success(stats);
    }

    @GetMapping("/recent")
    public AjaxResult getRecentLeaveApply() {
        List<Map<String, Object>> list = leaveStatsService.getRecentLeaveApplyList();
        return AjaxResult.success(list);
    }
} 